package org.geom;

public class Matrix {
	
	public static float[][] product(float[][] a, float[][] b) {
		int m = a.length;
		int n = b[0].length;
		float[][] ret = getNullMatrix(m, n);
						
//		if(a[0].length!=b.length) { 
//			throw new Exception("Matrici non coerenti.");
//		}
		
		for(int i=0; i<m; i++) {
			for(int j=0; j<n ; j++) {
				for(int k=0; k<b.length; k++) {
					ret[i][j] += (a[i][k]*b[k][j]);
				}
			}
		}
		return ret;
	}

	public static float[][] getNullMatrix(int m, int n) {
		float[][] ret = new float[m][n];
		
		for (int i = 0; i < ret.length; i++) {
			for (int j = 0; j < ret[0].length; j++) { 
				ret[i][j] = 0;
			}
		}
		
		return ret;
	}

}
